class Solution:
    def longestPalindrome(self, s: str) -> str:
        leng = len(s)
        maxLen = 1
        S = s[0]
        for i in range(leng):
            left, right = i, i
            while left >=0 and right < leng and s[left] == s[right]:
                left -= 1
                right += 1
            if right - left - 1 > maxLen:
                maxLen = right - left - 1
                S = s[left+1:right]

            left, right = i, i+1
            while left >=0 and right < leng and s[left] == s[right]:
                left -= 1
                right += 1
            if right - left - 1 > maxLen:
                maxLen = right - left - 1
                S = s[left+1:right]
        return S

if __name__ == '__main__':
    s = Solution()
    print(s.longestPalindrome("bbb"))